package com.tianlu.store.schedule;

import com.tianlu.store.service.OrderInfoService;
import com.tianlu.store.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author liangdl
 * @since 2023/4/14 11:28
 */
@Service
@Slf4j
public class OrderSchedule {
    @Resource
    OrderInfoService orderInfoService;
    @Resource
    UserInfoService userInfoService;

    /**
     * 发货14天后自动确认收货
     *
     * @author liangdl
     * @since 2023/4/14 11:33
     */
    @Scheduled(cron = "0 0 3 * * ? ")
//    @Scheduled(fixedRate = 5000)
    public void autoConfirm() {
        log.info("自动确认收货定时任务开始执行");
        orderInfoService.autoConfirm();
    }

    /**
     * 每周一重置免费商品的领取资格
     *
     * @author liangdl
     * @since 2023/4/14 11:33
     */
    @Scheduled(cron = "0 0 0 ? * MON")
    public void resettingFreeFlag() {
        log.info("重置免费商品的领取资格定时任务开始执行");
        userInfoService.resettingFreeFlag();
    }
}
